class Solution:
    def maxNumOfMarkedIndices(self, nums: list[int]) -> int:
        nums.sort()

        ans = 0
        k = len(nums) >> 1
        size = len(nums)
        (i, j) = (0, k)
        while i < k and j < size:
            while j < size and 2 * nums[i] > nums[j]:
                j += 1

            if j < size:
                ans += 2
                i += 1
                j += 1
        return ans